var express = require('express');
var router = express.Router();

const {  getUserCart,deleteUserCart,updataUserCart,addUserCart,
  updataOrder,addOrders,getGoods,
   getmendian,getOrders, getOrderById,deleteOrdersById } = require("../server/orderServer.js")

//获取购物车的数据
router.get('/getUserCart', async (req, res) => {
  res.send(await getUserCart(req.query));
});
//新增购物车的数据
router.post('/addUserCart', async (req, res) => {
  res.send(await addUserCart(req.body));
});

//修改购物车的数据
router.post('/updataUserCart', async (req, res) => {
  res.send(await updataUserCart(req.body));
});
//删除购物车的数据
router.post('/deleteUserCart', async (req, res) => {
  res.send(await deleteUserCart(req.body));
});

// 删除
router.post('/deleteOrdersById', async (req, res) => {
  res.send(await deleteOrdersById(req.body));
});
// 更新
router.post('/updataOrder', async (req, res) => {
  res.send(await updataOrder(req.body));
});
// 新增
router.post('/', async (req, res, next) => {
  const data = await addOrders(req.body)
  res.send(data)
});

//获取商品
router.get('/getGoods', async (req, res, next) => {
  const data = await getGoods(req.query)
  res.send(data)
});
//获取商品下的所有门店
router.get('/getmendian', async (req, res, next) => {
  console.log(111,req.query)
  const data = await getmendian(req.query)
  res.send(data)
});

//获取
router.get('/', async (req, res, next) => {
  const data = await getOrders(req.query)
  res.send(data)
});
//查看详情
router.post('/getOrderById', async (req, res) => {
  res.send(await getOrderById(req.body));
});
module.exports = router;